import {Injectable} from '@angular/core';
import { Http, Response, Headers, RequestOptions,URLSearchParams } from '@angular/http';
import 'rxjs/Rx';

@Injectable()
export class MyHttp {
  public restServer;
  public http;
  headers = new Headers();
  constructor(Http:Http) {
    this.http = Http;
    this.restServer = 'http://mzlocker.com/admin/'
  }

  public post(url,params:Object){
    var vm = this;
    //vm.headers.append('AUTHORIZATION','token 591e41f8f32d0');
    vm.headers.append('Content-Type', 'application/x-www-form-urlencoded');   
    let posttoken = {"access_token":"123456"} ;
    let postparams = {"access_token":""};
    postparams.access_token = posttoken.access_token;
    if(params){
     for(var key in params){
      postparams[key] = params[key] 
     }
    }
    return vm.http.post(vm.restServer + url,postparams,{headers:vm.headers})
    .map(res=>res.json())
    
  }

}